package com.zou.application.filter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class WebSecurityConfig extends WebMvcConfigurerAdapter{
	
	@Bean
    public UserSessionInter getUserSessionInter() {
        return new UserSessionInter();
    }
	
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(getUserSessionInter());

        // 排除配置
        addInterceptor.excludePathPatterns("/");
        addInterceptor.excludePathPatterns("/error");
        addInterceptor.excludePathPatterns("/admin/**");
        addInterceptor.excludePathPatterns("/customer/products");
        addInterceptor.excludePathPatterns("/customer/signle");
        addInterceptor.excludePathPatterns("/user/login");
        addInterceptor.excludePathPatterns("/user/usercenter");
        addInterceptor.excludePathPatterns("/contact/contactusPage");
        addInterceptor.excludePathPatterns("/user/customerLogin");
        addInterceptor.excludePathPatterns("/user/register");
        addInterceptor.excludePathPatterns("/shopcar/addCar");
        addInterceptor.excludePathPatterns("/user/customerRegister");
        addInterceptor.excludePathPatterns("/user/checkUserRegis");

        // 拦截配置
        addInterceptor.addPathPatterns("/**");
    }
}
